package com.bw.shopping.adapter;

import android.widget.CheckBox;

import com.bw.mvvm.network.load.LoadImage;
import com.bw.shopping.R;
import com.bw.mvvm.entity.CartEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class CartAdapter extends BaseQuickAdapter<CartEntity.DataBean, BaseViewHolder> {
    public CartAdapter() {
        super(R.layout.item_shopping_recycle);
        addChildClickViewIds(R.id.cart_rb);
        addChildClickViewIds(R.id.item_shopping_imag);
        addChildClickViewIds(R.id.item_shopping_state);
        addChildClickViewIds(R.id.item_shopping_value);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, CartEntity.DataBean dataBean) {
        LoadImage.loadMatchImg(dataBean.getGoods_icon(),baseViewHolder.getView(R.id.item_shopping_imag));
        baseViewHolder.setText(R.id.item_shopping_value,dataBean.getGoods_desc());
        baseViewHolder.setText(R.id.item_shopping_state, "价钱："+dataBean.getGoods_price()+"￥");
        baseViewHolder.setText(R.id.item_shopping_time, dataBean.getGoods_sku());

        CheckBox view = baseViewHolder.getView(R.id.cart_rb);
        view.setChecked(dataBean.isClick());
    }
}
